package com.zhan.ielts.web.controller.refleshdata;

import com.zhan.frame.core.web.domain.Result;
import com.zhan.ielts.service.refleshdata.IEncryptAndDecryptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by tlfu on 2017/1/3.
 */
@Controller
@RequestMapping("/refleshdata")
public class EncryptAndDecryptController {
    @Autowired
    private IEncryptAndDecryptService encryptAndDecryptService;

    @ResponseBody
    @RequestMapping(value = "/encryptUser", method = RequestMethod.POST)
    public Result encryptUser(boolean isEncrypt) {
        try {
            encryptAndDecryptService.updateEncryptUserData(isEncrypt);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Result.Status.ERROR, e.getMessage());
        }
        return new Result(Result.Status.OK, "刷数据成功！");
    }
    @ResponseBody
    @RequestMapping(value = "/encryptDynamicCode", method = RequestMethod.POST)
    public Result encryptDynamicCode(boolean isEncrypt) {
        try {
            encryptAndDecryptService.updateEncryptDynamicCode(isEncrypt);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Result.Status.ERROR, e.getMessage());
        }
        return new Result(Result.Status.OK, "刷数据成功！");
    }
}
